package org.openbiz.appbiz.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * 
 * @author Lasantha Ranaweera
 */
@Entity
@Table(name = "obt_who")
public class Who extends BaseObject implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1793158099197096042L;
	private Long did;
	private String name;
	private Long categoryDid;
	private Date createdDate;
	private Long createdWhoDid;
	private Date lastUpdatedDate;
	private Long lastUpdatedWhoDid;

	public Who() {
	}
	
	@Id @GeneratedValue(strategy=GenerationType.AUTO)
	public Long getDid() {
		return this.did;
	}

	public void setDid(Long did) {
		this.did = did;
	}
	
	@Column(nullable=false,length=50,unique=true)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name="category_did",nullable=false)
	public Long getCategoryDid() {
		return categoryDid;
	}

	public void setCategoryDid(Long categoryDid) {
		this.categoryDid = categoryDid;
	}
	
	@Column(name="created_date",nullable=false)
	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}
	
	@Column(name="created_who_did",nullable=false)
	public Long getCreatedWhoDid() {
		return createdWhoDid;
	}

	public void setCreatedWhoDid(Long createdWhoDid) {
		this.createdWhoDid = createdWhoDid;
	}
	
	public Date getLastUpdatedDate() {
		return lastUpdatedDate;
	}

	public void setLastUpdatedDate(Date lastUpdatedDate) {
		this.lastUpdatedDate = lastUpdatedDate;
	}

	public Long getLastUpdatedWhoDid() {
		return lastUpdatedWhoDid;
	}

	public void setLastUpdatedWhoDid(Long lastUpdatedWhoDid) {
		this.lastUpdatedWhoDid = lastUpdatedWhoDid;
	}

	/**
	 * {@inheritDoc}
	 */
	public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Who)) {
            return false;
        }

        Who obj = (Who) o;

        return !(name != null ? !name.equals(obj.getName()) : obj.getName() != null);

    }

	/**
	 * {@inheritDoc}
	 */
	public int hashCode() {
		return (name != null ? name.hashCode() : 0);
	}

	/**
	 * {@inheritDoc}
	 */
	public String toString() {
		ToStringBuilder sb = new ToStringBuilder(this,
				ToStringStyle.DEFAULT_STYLE).append("name", this.name);

		return sb.toString();
	}
}
